<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>Global Image - Folha de Pagamento</title>
            <link rel="stylesheet" type="text/css" href="/globalimage2/faces/jsfcrud.css" /><%@ include file="/WEB-INF/jspf/AjaxScripts.jspf" %><script type="text/javascript" src="/globalimage2/faces/jsfcrud.js"></script>
        </head>
        <body>
            <%@include file="../../WEB-INF/jspf/header/head.jspf"%>
            <div style="float:left">
                <%@include file="../../WEB-INF/jspf/header/menuDinamico.jspf"%>
            </div>
            <div id="div_content">
                <div class="bgContentTable">
                    <div class="titleTable"><h3>Folha de pagamento</h3></div><br />
                    <h:form styleClass="jsfcrud_list_form">
                        <h:panelGroup id="messagePanel" layout="block">
                            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                        </h:panelGroup>

                        &nbsp;&nbsp;<h:commandLink action="#{folhaPagamento.createSetup}" value="Novo"/>

                        <c:if test="${folhaPagamento.pagingInfo.itemCount == 0}">
                            <br /><br />&nbsp;&nbsp;<h:outputText escape="false" value="Não foi encontrado registros." rendered="#{folhaPagamento.pagingInfo.itemCount == 0}" />
                        </c:if>
                        <h:panelGroup rendered="#{folhaPagamento.pagingInfo.itemCount > 0}">
                            <div style="text-align:right;width:450px;float:right;margin-right:7px;">
                                <h:outputText value="Item #{folhaPagamento.pagingInfo.firstItem + 1}..#{folhaPagamento.pagingInfo.lastItem} de #{folhaPagamento.pagingInfo.itemCount}"/>&nbsp;
                                <h:commandLink action="#{folhaPagamento.prev}" value="Anterior #{folhaPagamento.pagingInfo.batchSize}" rendered="#{folhaPagamento.pagingInfo.firstItem >= folhaPagamento.pagingInfo.batchSize}"/>&nbsp;
                                <h:commandLink action="#{folhaPagamento.next}" value="Próximo #{folhaPagamento.pagingInfo.batchSize}" rendered="#{folhaPagamento.pagingInfo.lastItem + folhaPagamento.pagingInfo.batchSize <= folhaPagamento.pagingInfo.itemCount}"/>&nbsp;
                                <h:commandLink action="#{folhaPagamento.next}" value="Restantes #{folhaPagamento.pagingInfo.itemCount - folhaPagamento.pagingInfo.lastItem}"
                                               rendered="#{folhaPagamento.pagingInfo.lastItem < folhaPagamento.pagingInfo.itemCount && folhaPagamento.pagingInfo.lastItem + folhaPagamento.pagingInfo.batchSize > folhaPagamento.pagingInfo.itemCount}"/>
                            </div>
                            <h:dataTable value="#{folhaPagamento.folhaPagamentoItems}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px; width: 99%; margin-left: 5px;">
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Funcionário"/>
                                    </f:facet>
                                    <h:outputText value="#{item.funcionarioId.usuarioId.nome}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Data do Pagamento"/>
                                    </f:facet>
                                    <h:outputText value="#{item.dataPagamento}">
                                        <f:convertDateTime pattern="dd/ mm/ yyyy" />
                                    </h:outputText>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Salário"/>
                                    </f:facet>
                                    <h:outputText value="#{item.salario}">
                                        <f:convertNumber type="currency"/>
                                    </h:outputText>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Adiantamento"/>
                                    </f:facet>
                                    <h:outputText value="#{item.adiantamento}">
                                        <f:convertNumber type="currency"/>
                                    </h:outputText>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Extra"/>
                                    </f:facet>
                                    <h:outputText value="#{item.extra}">
                                        <f:convertNumber type="currency"/>
                                    </h:outputText>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Total"/>
                                    </f:facet>
                                    <h:outputText value="#{item.extra + item.salario}">
                                        <f:convertNumber type="currency"/>
                                    </h:outputText>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText escape="false" value="&nbsp;"/>
                                    </f:facet>
                                    <h:commandLink value="Exibir" action="#{folhaPagamento.detailSetup}">
                                        <f:param name="jsfcrud.currentFolhaPagamento" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][item][folhaPagamento.converter].jsfcrud_invoke}"/>
                                    </h:commandLink>
                                    <h:outputText value=" "/>
                                    <h:commandLink value="Editar" action="#{folhaPagamento.editSetup}">
                                        <f:param name="jsfcrud.currentFolhaPagamento" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][item][folhaPagamento.converter].jsfcrud_invoke}"/>
                                    </h:commandLink>
                                    <h:outputText value=" "/>
                                    <h:commandLink value="Remover" action="#{folhaPagamento.destroy}">
                                        <f:param name="jsfcrud.currentFolhaPagamento" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][item][folhaPagamento.converter].jsfcrud_invoke}"/>
                                    </h:commandLink>
                                </h:column>
                            </h:dataTable>
                        </h:panelGroup>

                    </h:form>
                </div>
            </div>
        </body>
    </html>
</f:view>
